﻿//***************************************************************************//
//                                                                           //
//Author:       Kris Henry                                                   //
//Class Name:   Fox.cs                                                       //
//Pupose:                                                                    //
//Date :        December 2012                                                //
//                                                                           //
//***************************************************************************//

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace Indie_Game_Contest
{
    class Fox : Enemy
    {
        bool flip;
        bool dead;

        public bool Dead
        {
            get { return dead; }
            set { dead = value; }
        }
        private EnemyAnimation enemy_Dead;

        internal EnemyAnimation Enemy_Dead
        {
            get { return enemy_Dead; }
            set { enemy_Dead = value; }
        }

        public bool Flip
        {
            get { return flip; }
            set { flip = value; }
        }
        AIState state = new AIState();
        public Fox()
        {
            state.Enemy = this;
        }
        private bool walk;

        public bool Walk1
        {
            get { return walk; }
            set { walk = value; }
        }
        private bool attacking;

        public bool Attacking
        {
            get { return attacking; }
            set { attacking = value; }
        }
        private bool standing;

        public bool Standing
        {
            get { return standing; }
            set { standing = value; }
        }
        private bool took_damage;

        public bool Took_damage
        {
            get { return took_damage; }
            set { took_damage = value; }
        }
        private EnemyAnimation attack;

        public EnemyAnimation Attack
        {
            get { return attack; }
            set { attack = value; }
        }
        private EnemyAnimation idle;

        public EnemyAnimation Idle
        {
            get { return idle; }
            set { idle = value; }
        }
        private EnemyAnimation damaged;

        public EnemyAnimation Damaged
        {
            get { return damaged; }
            set { damaged = value; }
        }
        private EnemyAnimation walking;

        public EnemyAnimation Walking
        {
            get { return walking; }
            set { walking = value; }
        }
        
         public override void Render()
        {
            if (!Dead)
            {
                if (Standing)
                    Idle.Draw(WorldData.spriteBatch, new Vector2(Position.X,Position.Y+3), new Vector2(4, 0), 0.0f, Scale, flip);
                else if (Attacking)
                    Attack.Draw(WorldData.spriteBatch, new Vector2(Position.X, Position.Y + 3), new Vector2(5, 0), 0.0f, Scale, flip);
                else if (Took_damage)
                    Damaged.Draw(WorldData.spriteBatch, new Vector2(Position.X, Position.Y + 3), new Vector2(3, 0), 0.0f, Scale, flip);
                else if (Walk1)
                    Walking.Draw(WorldData.spriteBatch, new Vector2(Position.X, Position.Y + 20), new Vector2(7, 0), 0.0f, Scale, flip);
            }
            else
                Enemy_Dead.Draw(WorldData.spriteBatch, new Vector2(Position.X, Position.Y + 3), new Vector2(8, 0), 0.0f, Scale, flip);
        }
        public override  void Update(float dt)
        {
            base.Update(dt);
            float scalar = 0;
            Vector2 temp_player_pos = GameplayState.Instance.Player.Position;
            temp_player_pos.Normalize();
            Vector2 temp_enemy_pos = Position;
            temp_enemy_pos.Normalize();
            scalar = Vector2.Dot(temp_enemy_pos, temp_player_pos);

            if (temp_enemy_pos.X < temp_player_pos.X)
                flip = false;
            else
                Flip = true;
            if (Health <= 0)
                dead = true;
            else
                dead = false;
            if (Velocity.X == 0 && Velocity.Y == 0)
            {
                Standing = true;
                Walk1 = false;
            }
            else
            {
                Standing = false;
                Walk1 = true;
            }

            if (Attack1)
                Attacking = true;
            else 
                Attacking = false;
            state.Update(dt,this);
            Idle.Update(10);
            Walking.Update(10);
            Damaged.Update(10);
            Attack.Update(10);
            Enemy_Dead.Update(10);

        }
    }
}
